﻿using System;

namespace DevelopersTestPad.Worksheets.DotNet
{
    /// <summary>
    /// Displays output messages.
    /// </summary>
    internal partial class OutputSubView : SubView
    {
        public OutputSubView()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Adds a message into the output sub view.
        /// </summary>
        /// <param name="message">The message to add.</param>
        public void Add(string message)
        {
            fastColoredTextBox.AppendText(message + Environment.NewLine);
            fastColoredTextBox.GoEnd();
        }

        #region ContextMenu

        private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            mniClearAll.Enabled = !string.IsNullOrEmpty(fastColoredTextBox.Text);
            mniCopy.Enabled = !string.IsNullOrEmpty(fastColoredTextBox.SelectedText);
        }

        /// <summary>
        /// Clear all text.
        /// </summary>
        private void mniClearAll_Click(object sender, EventArgs e)
        {
            fastColoredTextBox.Clear();
        }

        /// <summary>
        /// Copy selected text into Clipboard
        /// </summary>
        private void mniCopy_Click(object sender, EventArgs e)
        {
            fastColoredTextBox.Copy();
        }

        #endregion

    }
}
